var UserCon = iClass.get("User");
var db = iClass.db;
iClass.method("Admin", {
	getUserList: function(num, page) {
		var user_list = db.find_all(UserCon.dbname)

		//处理参数
		var total_num = user_list.length;
		num = ~~num;
		num > 0 || (num = total_num); //num > 0
		page = ~~page;
		page >= 0 || (page = 0); //page >= 0
		var total_page = Math.ceil(total_num / num) || 1;
		//整理数据
		user_list = user_list.slice().reverse().page(num, page);

		return {
			total_num: total_num,
			total_page: total_page,
			num: num,
			page: page,
			list: user_list
		};
	},
	//代码片段
	_getUser: function(user_id) {
		var user = UserCon.get(user_id);
		if (!user) {
			Throw("找不到指定用户")
		}
		return user;
	},
	lockUser: function(user_id) {
		var user = this._getUser(user_id);
		user._lock();
		return user;
	},
	unlockUser: function(user_id) {
		var user = this._getUser(user_id);
		user._unlock();
		return user;
	}
});